/**
 * @author Francesco Rosso, matr 592057
 */

package pcd1112.model;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.PrintWriter;
import java.rmi.RemoteException;
import java.rmi.server.UnicastRemoteObject;

public class TxtWriterImpl extends UnicastRemoteObject implements TxtWriter {

	private static final long serialVersionUID = 1L;
	PrintWriter writer;

	public TxtWriterImpl() throws RemoteException, FileNotFoundException {
		super();
		writer = new PrintWriter(new File("output.txt"));
	}

	/**
	 * Appends a line to the file "output.txt"
	 */
	@Override
	public void append(String text) throws RemoteException {
		System.out.println("Writing in output.txt");
		writer.println(text);
		writer.flush();
	}

}
